<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="row">

	<div class="col-sm-9">
		<h4>Establecimientos <small>({{results.totalItems}} resultados)</small></h4>
		<div class="m-top-15">
			<div ng-if="results.results.length < 1">No se han encontrado resultados</div>
			<ul class="list-group">
				<li class="list-group-item" ng-repeat="result in results.results">
					<div>
						<a href="#/stores/id/{{result.id}}">{{result.name}}</a>
						<span class="pull-right">{{result.parent.name}} - {{result.address.province.name}}</span>
					</div>
				</li>
			</ul>
			<div class="pull-right">
				<a href="#">Nuevo establecimiento</a>
			</div>
			<pagination total-items="results.totalItems" page="results.currentPage" items-per-page="results.itemsPerPage" on-select-page="setPage(page)" max-size="10" boundary-links="true" first-text="Primero" previous-text="Anterior" next-text="Siguiente" last-text="Último"></pagination>
		</div>
	</div>
	<div class="col-sm-3">
		<div>
			<h4>Filtrar resultados</h4>
			<form role="form">
				<div class="form-group">
					<label>Nombre</label>
					<input type="text" class="form-control input-sm" ng-model="searchName" placeholder="Nombre" />
				</div>
				<div class="form-group">
					<label>Empresa</label>
					<input type="text" class="form-control input-sm" ng-model="searchCompany" placeholder="Empresa" typeahead="company as company.name for company in companies($viewValue)" />
				</div>
				<div class="form-group">
					<label>Provincia</label>
					<input type="text" class="form-control input-sm" ng-model="searchProvince" placeholder="Provincia" typeahead="province as province.name for province in provinces($viewValue)" />
				</div>
				<div class="form-group">
					<label>Centro de coste</label>
					<input type="text" class="form-control input-sm" ng-model="searchCostCenter" placeholder="Centro de coste" typeahead="center as center.name for center in costcenters($viewValue)"/>
				</div>
				<button class="btn btn-primary btn-sm" ng-click="search()">Buscar</button>
			</form>
		</div>
		<!-- popup con el json de debug -->
		<div class="m-top-40">
			<button class="btn btn-default btn-sm" data-toggle="modal" data-target="#debugJson">Ver JSON</button>
			<div class="modal fade" id="debugJson" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<pre>entity = {{results | json}}</pre>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>